const { resolve } = require('path');
const webpack = require('webpack');
const  path_t=resolve(__dirname);
const p_path=path_t+"/component/new_contain/";
module.exports = {
    // cheap-module-eval-source-map
    //devtool: "inline-source-map",//可以在 浏览器报错时看到在哪里 报错
    // context: resolve(__dirname, 'src'),
    entry: {
        app:[
            resolve(__dirname, 'component/new_contain/app.jsx'),
            'react-hot-loader/patch',
            // activate HMR for React

            'webpack-dev-server/client?http://localhost:8081',
            // bundle the client for webpack-dev-server
            // and connect to the provided endpoint

            'webpack/hot/only-dev-server',
            // bundle the client for hot reloading
            // only- means to only hot reload for successful updat
            ],
        vendor: ['react-router',"./use_rem.js"],
        // // the entry point of our app.jsx
        // getSex:p_path+'Bus.js',
        // getW:p_path+'Cart.js',
        // getH:p_path+'Height.js',
        // getA:p_path+'get_age.js'
    },
    output: {
        path: resolve(__dirname, 'dist'),
        filename: '[name].js',
        chunkFilename: '[name].chunk.js',
        publicPath: './dist/'
    },
    module: {
        rules: [
            {
                test: /\.jsx?||\.js?$/,
                loader: 'babel-loader',
                exclude: /^node_modules|dist$/,
                query: {
                    presets: [
                        'react',
                        'es2015'
                    ]
                }
            },
            // {
            //     test: /[test_loading]$/,
            //     loader: 'babel-loader',
            //     exclude: /^node_modules|dist$/,
            // },
            {
                test: /\.css$/,
                use: [ 'style-loader', 'css-loader?modules', ],
            }
        ]
    },
    plugins: [
        //new webpack.HotModuleReplacementPlugin(),
        // enable HMR globally
        // new webpack.HotModuleReplacementPlugin(),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            // minChunks: Infinity,
            filename: '[name].js',
        }),
        new webpack.HotModuleReplacementPlugin(),
        // enable HMR globally

        new webpack.NamedModulesPlugin(),
        // prints more readable module names in the browser console on HMR updates

        //new webpack.NamedModulesPlugin(),
        // prints more readable module names in the browser console on HMR updates
    ],
    externals: {
        "react" : 'React',
        "react-dom":"ReactDOM"
    }
};
